package com.example.activiti7.domain.model.req;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 分页查询场景，请求基类，主要用于扩展在请求参数对象上
 * e.g. extends BasePageReq
 *
 * @author PD
 */
public abstract class BasePageReq extends BaseRequest {
    /**
     * 当前页码
     */
    @Schema(description = "当前页码", defaultValue = "1")
    private int pageIndex = 1;
    /**
     * 每页展示条数
     */
    @Schema(description = "每页展示条数", defaultValue = "15")
    private int pageSize = 15;
    /**
     * 排序字段
     */
    @Schema(description = "排序字段")
    private String sortField;
    /**
     * 排序类型 DESC:倒序,ASC:正序
     */
    @Schema(description = "排序类型 DESC:倒序,ASC:正序", defaultValue = "DESC")
    private String sortType = "DESC";

    public int getPageIndex() {
        return pageIndex < 1 ? 1 : pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getSortType() {
        return sortType;
    }

    public void setSortType(String sortType) {
        this.sortType = sortType;
    }
}
